package com.example.gzysmartcity.ui.adapter;

import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.youth.banner.adapter.BannerAdapter;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

public class BrStringAdapter extends BannerAdapter<String, BrStringAdapter.VH> {
    public BrStringAdapter(ArrayList<String> datas) {
        super(datas);
    }


    @Override
    public VH onCreateHolder(ViewGroup parent, int viewType) {
        ImageView imageView = new ImageView(parent.getContext());
        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        imageView.setLayoutParams(layoutParams);
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        return new VH(imageView);
    }

    @Override
    public void onBindView(VH holder, String data, int position, int size) {
        Glide.with(holder.imageView).load(data).into(holder.imageView);
    }

    public static class VH extends RecyclerView.ViewHolder {
        ImageView imageView;

        public VH(@NonNull @NotNull ImageView itemView) {
            super(itemView);
            imageView = itemView;
        }
    }
}
